university of illinois researchers gave 150 children a pattern game .
it was designed to test cognitive flexibility , which is our ability to shift attention and select information to fit the changing demands of a task .
they compared the results with the children 's food diaries .
found those who ate fatty food had slower reaction times and worse working memories than children who ate healthier diets .